
import { SlateElement } from '@wangeditor/editor'
import { ActivityElement } from './custom-types'
import { ActivityElementTypeName } from './config'

// 生成 html 的函数
function attachmentToHtml(elem: ActivityElement, childrenHtml: string): string {
    const { href = '', name, id, miniprogramAppid, miniprogramPath } = elem
    let commonAttrStr = `data-w-e-type="${ActivityElementTypeName}" data-w-e-is-void data-w-e-is-inline actId="${id}"`
    if (miniprogramAppid) {
        return `<a ${commonAttrStr} data-miniprogram-appid="${miniprogramAppid}" data-miniprogram-path="${miniprogramPath}">${name}</a>`
    }
    return `<a ${commonAttrStr} href="${href}" >${name}</a>`
}

// 配置
const conf = {
    type: ActivityElementTypeName,
    elemToHtml: attachmentToHtml,
} as any

export default conf
